package com.gqb.wangyi;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class huawei4 {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		while (scanner.hasNext()) {
			int p=scanner.nextInt();
			int n=scanner.nextInt();
			Map<Integer, Integer> kuang=new HashMap<>();
			for (int i = 0; i < p; i++) {
				kuang.put(i, 0);
			}
			List<Integer> basketballs=new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				basketballs.add(scanner.nextInt());
			}
			int count=0;
			boolean tag=true;
			for (int i = 0; i < basketballs.size(); i++) {
				if(kuang.get(basketballs.get(i)%p)==1){
					System.out.println(i+1);
					tag=false;
					break;
				}else{
					kuang.put(basketballs.get(i)%p, 1);
					count++;
				}
			}
			if(tag){
				System.out.println(-1);
			}
			
		}
		scanner.close();
	}
}
